from web3 import Web3
from config.config import convert_to_object

def get_eth_connection():
    # db_config,block_chain_config  = convert_to_object()
    web3 = Web3(Web3.HTTPProvider('https://eth-mainnet.g.alchemy.com/v2/oKmOQKbneVkxgHZfibs-iFhIlIAl6HDN'))

    if web3.is_connected():
        print("Connected to Ethereum node")
    else :
        print("Fail to connnect Ethereum node")
        exit(1)
    
    # 获取当前区块高度
    block_number = web3.eth.block_number
    print("Current block number:", block_number)

if __name__ == '__main__':
    get_eth_connection()